﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.SessionState;
using ServiceStack.Redis;
using RedisSessionStore.Configuration;
using RedisSessionStore.Redis;

namespace RedisSessionStore.WithLock
{
	public class RedisWithLockSessionStateItemsCollection : RedisSessionStore.NoLock.RedisNoLockSessionStateItemsCollection
	{

		public RedisWithLockSessionStateItemsCollection(string id, int timeout, string redisServer, int redisDb)
			: base(id, timeout, redisServer, redisDb)
		{
			_items = new Dictionary<string, object>();
		}

		#region ISessionStateItemCollection Members
		public void Clear() 
		{ 
			
		}

		public System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys
		{
			get
			{
				
			}
		}

		public void Remove(string name)
		{

		}

		public object this[string name]
		{
			get
			{
				string key = GetKey(name);
				using (var redis = SingleRedisPool.GetClient(_redisServer))
				{
					return redis.Get<object>(key);
				}
			}
			set
			{
				string key = GetKey(name);
				using (var redis = SingleRedisPool.GetClient(_redisServer))
				{
					bool result = redis.Set<object>(key, value);
				}
			}
		}

		#endregion

		#region ICollection Members

		public void CopyTo(Array array, int index)
		{
			throw new NotImplementedException();
		}

		public int Count
		{
			get { throw new NotImplementedException(); }
		}

		public bool IsSynchronized
		{
			get { throw new NotImplementedException(); }
		}

		public object SyncRoot
		{
			get { throw new NotImplementedException(); }
		}

		#endregion

		#region IEnumerable Members

		public System.Collections.IEnumerator GetEnumerator()
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}
